
<%@ page import="myschool.entity.Subject" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="myschool.util.MybatisUtil" %>
<%@ page import="myschool.dao.GradeDao" %>
<%@ page import="myschool.dao.SubjectDao" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
  request.setCharacterEncoding("utf-8");
  String subId = request.getParameter("id");
  String newSubjectName=request.getParameter("subjectName");
  String classHour = request.getParameter("classHour");
  String gradeID = request.getParameter("gradeID");

  Subject subject = new Subject();
  //subject.setId(Long.parseLong(subId));
   subject.setId((Long)session.getAttribute("subId"));

    subject.setSubjectname(newSubjectName);
   
    subject.setClasshour(Integer.parseInt(classHour));
  
  subject.setGradeid(Long.parseLong(gradeID));

  SqlSession s= MybatisUtil.get();
  SubjectDao mapper = s.getMapper(SubjectDao.class);
  mapper.update(subject);
  MybatisUtil.close(s);
  response.sendRedirect("subject.jsp");
%>

</body>
</html>
